package com.yiwei.hdb.impl;

import android.content.Context;
import android.text.TextUtils;

import com.yiwei.hdb.constant.Const;
import com.yiwei.hdb.http.CallBackListener;
import com.yiwei.hdb.http.InterfaceServer;
import com.yiwei.hdb.interfaces.BankInfo;
import com.yiwei.hdb.http.InfoCallBack;
import com.yiwei.hdb.model.ApplyModel;
import com.yiwei.hdb.model.BankListModel;
import com.yiwei.hdb.model.BankModel;
import com.yiwei.hdb.model.RequestModel;
import com.yiwei.hdb.model.ResponseModel;

import java.util.HashMap;

public class BankInfoImpl implements BankInfo {

    public void getBankCardno(Context paramContext, String paramString, final InfoCallBack callBack) {
        HashMap localHashMap = new HashMap();
        localHashMap.put("cardno", paramString);
        RequestModel model = new RequestModel(localHashMap);

        InterfaceServer.getInstance(paramContext.getApplicationContext()).requestInterface(Const.BANK_CARDNO, Const.RequestMethod.POST, model, Const.DEFAULT_TIMEOUT, new CallBackListener<BankModel>(BankModel.class,callBack));
//                new ResponseListener() {
//
//            @Override
//            public void onFinishInMainThread(Object paramAnonymousObject) {
//            }
//
//            @Override
//            public void onStartInMainThread(Object paramAnonymousObject) {
//                callBack.onFailure(paramAnonymousObject.toString());
//            }
//
//            @Override
//            public void onSuccessInMainThread(int paramAnonymousInt, String paramAnonymousString, Object result) {
//                try {
//                    BankModel model = (BankModel) result;
//                    if (model.getStatus() == 1)
//                        callBack.onSuccess(model);
//                    else callBack.onFailure(model.getMsg());
//                    //返回数据接口
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public Object onSuccessInRequestThread(int statusCode, String content) {
//                try {
//                    return JsonUtil.<BankModel>fromJson(content, BankModel.class);
//                } catch (Exception e) {
//                    return null;
//                }
//            }
//        });
    }

    public void getBankCode(Context paramContext, String paramString1, String paramString2, final InfoCallBack callBack) {
        HashMap localHashMap = new HashMap();
        localHashMap.put("token", paramString1);
        localHashMap.put("verify_code", paramString2);
        RequestModel model = new RequestModel(localHashMap);
        InterfaceServer.getInstance(paramContext.getApplicationContext()).requestInterface(Const.BANK_CODE, Const.RequestMethod.POST, model, Const.DEFAULT_TIMEOUT,new CallBackListener<ResponseModel>(ResponseModel.class,callBack));
//                new ResponseListener() {
//            public void onFinishInMainThread(Object paramAnonymousObject) {
//            }
//
//            public void onStartInMainThread(Object paramAnonymousObject) {
//                callBack.onFailure(paramAnonymousObject.toString());
//            }
//
//            @Override
//            public void onSuccessInMainThread(int paramAnonymousInt, String paramAnonymousString, Object result) {
//                try {
//                    ResponseModel model = (ResponseModel) result;
//                    if (model.getStatus() == 1)
//                        callBack.onSuccess(model.getMsg());
//                    else callBack.onFailure(model.getMsg());
//                    //返回数据接口
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public Object onSuccessInRequestThread(int statusCode, String content) {
//                try {
//                    return JsonUtil.<ResponseModel>fromJson(content, ResponseModel.class);
//                } catch (Exception e) {
//                    return null;
//                }
//            }
//        });
    }

    public void getBankInfo(Context paramContext, String paramString1, String paramString2, String paramString3, String paramString4, final InfoCallBack callBack) {
        HashMap localHashMap = new HashMap();
        localHashMap.put("cardno", paramString1);
        localHashMap.put("bank_name", paramString2);
        localHashMap.put("bank_id", paramString3);
        localHashMap.put("bank_mobile", paramString4);
        RequestModel model = new RequestModel(localHashMap);
        InterfaceServer.getInstance(paramContext.getApplicationContext()).requestInterface(Const.BANKCARD, Const.RequestMethod.POST, model, Const.DEFAULT_TIMEOUT,new CallBackListener<ResponseModel>(ResponseModel.class,callBack));
//                new ResponseListener() {
//
//            @Override
//            public void onFinishInMainThread(Object paramAnonymousObject) {
//            }
//
//            @Override
//            public void onStartInMainThread(Object paramAnonymousObject) {
//                callBack.onFailure(paramAnonymousObject.toString());
//            }
//
//            @Override
//            public void onSuccessInMainThread(int paramAnonymousInt, String paramAnonymousString, Object result) {
//                try {
//                    ResponseModel model = (ResponseModel) result;
//                    if (model.getStatus() == 1)
//                        callBack.onSuccess(model);
//                    else callBack.onFailure(model.getMsg());
//                    //返回数据接口
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public Object onSuccessInRequestThread(int statusCode, String content) {
//                try {
//                    return JsonUtil.<ResponseModel>fromJson(content, ResponseModel.class);
//                } catch (Exception e) {
//                    return null;
//                }
//            }
//        });
    }

    public void getBankRealname(Context paramContext, final InfoCallBack callBack) {
        RequestModel localRequestModel = new RequestModel(new HashMap());
        RequestModel model = new RequestModel(localRequestModel);

        InterfaceServer.getInstance(paramContext.getApplicationContext()).requestInterface(Const.REALNAME, Const.RequestMethod.GET, model, Const.DEFAULT_TIMEOUT, new CallBackListener<BankModel>(BankModel.class,callBack));
//                new ResponseListener() {
//            @Override
//            public void onFinishInMainThread(Object paramAnonymousObject) {
//            }
//
//            @Override
//            public void onStartInMainThread(Object paramAnonymousObject) {
//                callBack.onFailure(paramAnonymousObject.toString());
//            }
//
//            @Override
//            public void onSuccessInMainThread(int paramAnonymousInt, String paramAnonymousString, Object result) {
//                try {
//                    BankModel model = (BankModel) result;
//                    if (model.getStatus() == 1)
//                        callBack.onSuccess(model);
//                    else callBack.onFailure(model.getMsg());
//                    //返回数据接口
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public Object onSuccessInRequestThread(int statusCode, String content) {
//                try {
//                    return JsonUtil.<BankModel>fromJson(content, BankModel.class);
//                } catch (Exception e) {
//                    return null;
//                }
//            }
//        });
    }

    public void getSaveInfo(Context paramContext, String paramString, final InfoCallBack callBack) {
        HashMap localHashMap = new HashMap();
        localHashMap.put("cardno", paramString);
        RequestModel model = new RequestModel(localHashMap);
        InterfaceServer.getInstance(paramContext.getApplicationContext()).requestInterface(Const.BANK_SAVE, Const.RequestMethod.POST, model, Const.DEFAULT_TIMEOUT,new CallBackListener<BankModel>(BankModel.class,callBack));
//                new ResponseListener() {
//
//            @Override
//            public void onFinishInMainThread(Object paramAnonymousObject) {
//            }
//
//            @Override
//            public void onStartInMainThread(Object paramAnonymousObject) {
//                callBack.onFailure(paramAnonymousObject.toString());
//            }
//
//            @Override
//            public void onSuccessInMainThread(int paramAnonymousInt, String paramAnonymousString, Object result) {
//                try {
//                    BankModel model = (BankModel) result;
//                    if (model.getStatus() == 1)
//                        callBack.onSuccess(model.getMsg());
//                    else callBack.onFailure(model.getMsg());
//                    //返回数据接口
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public Object onSuccessInRequestThread(int statusCode, String content) {
//                try {
//                    return JsonUtil.<BankModel>fromJson(content, BankModel.class);
//                } catch (Exception e) {
//                    return null;
//                }
//            }
//        });
    }

    @Override
    public void getAuthInfo(Context paramContext, String bankcard, String mobile, String verify_code, final InfoCallBack callBack) {
        HashMap localHashMap = new HashMap();
        localHashMap.put("bankcard", bankcard);
        localHashMap.put("mobile", mobile);
        if (!TextUtils.isEmpty(verify_code))
            localHashMap.put("verify_code", verify_code);
        RequestModel model = new RequestModel(localHashMap);
        InterfaceServer.getInstance(paramContext.getApplicationContext()).requestInterface(Const.AUTH, Const.RequestMethod.POST, model, Const.DEFAULT_TIMEOUT,new CallBackListener<ResponseModel>(ResponseModel.class,callBack));
//                new ResponseListener() {
//
//            @Override
//            public void onFinishInMainThread(Object paramAnonymousObject) {
//            }
//
//            @Override
//            public void onStartInMainThread(Object paramAnonymousObject) {
//                callBack.onFailure(paramAnonymousObject.toString());
//            }
//
//            @Override
//            public void onSuccessInMainThread(int paramAnonymousInt, String paramAnonymousString, Object result) {
//                try {
//                    ResponseModel model = (ResponseModel) result;
//                    if (model.getStatus() == 1)
//                        callBack.onSuccess(model.getMsg());
//                    else callBack.onFailure(model.getMsg());
//                    //返回数据接口
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public Object onSuccessInRequestThread(int statusCode, String content) {
//                try {
//                    return JsonUtil.<ResponseModel>fromJson(content, ResponseModel.class);
//                } catch (Exception e) {
//                    return null;
//                }
//            }
//        });
    }

    @Override
    public void getBankList(Context mContext, final InfoCallBack callBack) {
        RequestModel localRequestModel = new RequestModel(new HashMap());
        RequestModel model = new RequestModel(localRequestModel);

        InterfaceServer.getInstance(mContext.getApplicationContext()).requestInterface(Const.BANK_LIST, Const.RequestMethod.GET, model, Const.DEFAULT_TIMEOUT, new CallBackListener<BankListModel>(BankListModel.class,callBack));
//                new ResponseListener() {
//            @Override
//            public void onFinishInMainThread(Object paramAnonymousObject) {
//            }
//
//            @Override
//            public void onStartInMainThread(Object paramAnonymousObject) {
//                callBack.onFailure(paramAnonymousObject.toString());
//            }
//
//            @Override
//            public void onSuccessInMainThread(int paramAnonymousInt, String paramAnonymousString, Object result) {
//                try {
//                    BankListModel model = (BankListModel) result;
//                    if (model.getStatus() == 1)
//                        callBack.onSuccess(model);
//                    else callBack.onFailure(model.getMsg());
//                    //返回数据接口
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public Object onSuccessInRequestThread(int statusCode, String content) {
//                try {
//                    return JsonUtil.<BankListModel>fromJson(content, BankListModel.class);
//                } catch (Exception e) {
//                    return null;
//                }
//            }
//        });
    }

    @Override
    public void getApply(Context mContext, final InfoCallBack callBack) {
        RequestModel localRequestModel = new RequestModel(new HashMap());
        RequestModel model = new RequestModel(localRequestModel);

        InterfaceServer.getInstance(mContext.getApplicationContext()).requestInterface(Const.APPLY, Const.RequestMethod.GET, model, Const.DEFAULT_TIMEOUT,new CallBackListener<ApplyModel>(ApplyModel.class,callBack));
//                new ResponseListener() {
//            @Override
//            public void onFinishInMainThread(Object paramAnonymousObject) {
//            }
//
//            @Override
//            public void onStartInMainThread(Object paramAnonymousObject) {
//                callBack.onFailure(paramAnonymousObject.toString());
//            }
//
//            @Override
//            public void onSuccessInMainThread(int paramAnonymousInt, String paramAnonymousString, Object result) {
//                try {
//                    ApplyModel model = (ApplyModel) result;
//                    if (model.getStatus() == 1)
//                        callBack.onSuccess(model);
//                    else callBack.onFailure(model.getMsg());
//                    //返回数据接口
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public Object onSuccessInRequestThread(int statusCode, String content) {
//                try {
//                    return JsonUtil.<ApplyModel>fromJson(content, ApplyModel.class);
//                } catch (Exception e) {
//                    return null;
//                }
//            }
//        });
    }
}